From 3cce983db4f6f92d4e9053ffec6c4a3669b9de6a Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Thu, 15 Feb 2024 21:53:55 +0100 Subject: [PATCH] github-merge-pr: add option to use SSH key for github auth Add option to use SSH key for github auth. To enable this, edit the script and uncomment the USE_SSH=1 line. Signed-off-by: Christian Marangi --- github-merge-pr.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/github-merge-pr.sh b/github-merge-pr.sh index 863d3b7..b30b519 100755 --- a/github-merge-pr.sh +++ b/github-merge-pr.sh @@ -9,6 +9,9 @@ REPO="openwrt/openwrt" # - Enter a description, e.g. "pr.sh" and pick the "repo" scope # - Hit "Generate token" #TOKEN="d41d8cd98f00b204e9800998ecf8427e" +# +# Uncomment this line to use SSH key to rebase PR branch +# USE_SSH=1 PRID="$1" BRANCH="${2:-master}" @@ -75,7 +78,11 @@ fi PR_USER="$(echo "$PR_INFO" | jq -r ".head.user.login")" PR_BRANCH="$(echo "$PR_INFO" | jq -r ".head.ref")" LOCAL_PR_BRANCH="$PR_BRANCH"-"$PR_USER" -PR_REPO="$(echo "$PR_INFO" | jq -r ".head.repo.html_url")" +if [ "$USE_SSH" = "1" ]; then + PR_REPO="$(echo "$PR_INFO" | jq -r ".head.repo.ssh_url")" +else + PR_REPO="$(echo "$PR_INFO" | jq -r ".head.repo.html_url")" +fi if ! $GIT remote get-url $PR_USER &> /dev/null || [ -n "$DRY_RUN" ]; then echo "Adding $PR_USER with repo $PR_REPO to remote" -- 2.30.2